const getDefaultState = () => {
  return {
    name: "",
    avatar: ""
  };
};

const state = getDefaultState();

const mutations = {
  RESET_STATE: state => {
    Object.assign(state, getDefaultState());
  },
  SET_TOKEN: (state, token) => {
    state.token = token;
  },
  SET_NAME: (state, name) => {
    state.name = name;
  },
  SET_AVATAR: (state, avatar) => {
    state.avatar = avatar;
  }
};

const actions = {
  // user login
};

// // get user info
// getInfo ({ commit, state }) {
//   return new Promise((resolve, reject) => {
//     // eslint-disable-next-line no-undef
//     getInfo(state.token).then(response => {
//       const { data } = response
//
//       if (!data) {
//         // eslint-disable-next-line prefer-promise-reject-errors
//         reject('Verification failed, please Login again.')
//       }
//
//       const { name, avatar } = data
//
//       commit('SET_NAME', name)
//       commit('SET_AVATAR', avatar)
//       resolve(data)
//     }).catch(error => {
//       reject(error)
//     })
//   })
// },
//

// remove token

export default {
  namespaced: true,
  state,
  mutations,
  actions
};
